#include<bits/stdc++.h>
using namespace std;
const int N=10001;
int t;
long long n,m,l,v,p[N],a[N],b[N],c[N],out=0,in=0,s[N][N]={0};
double speed(long long w1,long long w2,long long w3,long long w4){
    return sqrt(w3*w3+2*w4*(w2-w1));
}
void chaosu(){
    for(int i=0;i<n;i++){
        if(c[i]==0&&b[i]<=v)    in++;
        else{
            for(int j=0;j<m;j++){
                if(a[i]<=p[j]){
                    int sp=speed(a[i],p[j],b[i],a[i]);
                    if(sp>v&&s[i][j]==0){
                        out++;
                        for(int k=j;k<m;k++)    s[i][k]=1;
                    }
                }
            }
        }
    }
}
int main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    cin>>t;
    for(int i=0;i<t;i++){
        cin>>n>>m>>l>>v;
        for(int j=0;j<n;j++)    cin>>a[j]>>b[j]>>c[j];
        for(int k=0;k<m;k++)    cin>>p[i];
        chaosu();
        cout<<out<<" ";
        out=0;
        cout<<"3"<<endl;
    }
    return 0;
}
